<template>
  <div>
    <table-data ref="table" :config="table_config" :searchFormConfig="search_form_config">
    </table-data>
  </div>
</template>

<script>
import TableData from "@c/tableData"
import { UpdateRealName,Blacklist,AmountClear } from "@/api/member.js"


export default {
  name: "Parking",
  components: {
    TableData
  },
  data() {
    return {
      dataId: "",
      rowId: "",
      switch_disabled: "",
      dialog_show: false,
      value: "",
      form: {
        brand: "",
        type: ""
      },
      options: [],
      table_config: {
        thead:[
          {label:"用户名",prop:"username"},
          {label:"真实姓名",prop:"truename"},
          {label:"租车订单",prop:"order"},
          {label:"违章预金额",prop:"illegalAmount"},
          {label:"押金",prop:"gilding"},
          {label:"余额",prop:"amount"},
          {label:"实名认证",prop:"check_real_name",type:"switch",handler:(data)=>this.handleAuth(data,'identity')},
          {label:"驾驶证认证",prop:"check_cars",type:"switch",handler:(data)=>this.handleAuth(data,'drive')},
          {label:"黑名单",prop:"blacklist",type:"switch",handler:(data)=>this.handleBlack(data)},
          {
            label:"操作",
            type: "operation",
            width: 300,
            buttonGroup: [
              {event:"link",label:"详情",type:"primary",name:"MemberDetailed",key:"id",value:"memberId"},
              {event:"link",label:"编辑",type:"primary",name:"MemberInfo",key:"id",value:"memberId"},
              {event:"button",label:"金额清空",type:"primary",handler:(data)=>this.handleAmountClear(data)},
            ],
            default: {
              deleteBtn: true,
              deleteKey: "memberId"
            },
            slotName: "operation"
          },
        ],
        url: "memberList",
        data: {
          pageSize: 10,
          pageNumber: 1
        }
      },
      search_form_config: {
        form_item: [
          {label:"关键字",type:"Keyword",options:["username","truename","card_id"]}
        ],
      },
    }
  },
  methods: {
    handleAmountClear(data) {
      AmountClear({member_id:data.memberId}).then((res) => {
        this.$message({
          type: "success",
          message: res.message
        })
        this.$store.commit("common/SET_TABLE_DATA_FLAG");
      })
    },
    handleBlack(data) {
      Blacklist({
        id: data.memberId,
        status: data.blacklist
      }).then((res) => {
        this.$message({
          message: res.message,
          type: "success"
        })
      })
    },
    handleAuth(data,type) {
      UpdateRealName({
        id: data.memberId,
        status: data.check_real_name,
        type
      }).then((res) => {
        this.$message({
          message: res.message,
          type: "success"
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>